package leetcode_601_700;

import java.util.HashSet;
import java.util.Set;

public class LeeCode_645 {
    public static void main(String[] args) {

    }
    public int[] findErrorNums(int[] nums) {
        int n = nums.length;
        Set<Integer> set = new HashSet<>();
        int a0 = 0, a1 = 0;
        for (int num : nums) {
            if (set.contains(num)){
                a0 = num;
            }
            set.add(num);
        }
        for (int i = 1; i <= n; i++) {
            if (!set.contains(i)){
                a1 = i;
                break;
            }
        }
        return new int[]{a0, a1};
    }
}
